package com.example.demo;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.Set;

public class Redis_set {
    public static void test01(Jedis jedis){
        System.out.println("sadd");
        jedis.flushAll();
        jedis.sadd("key","111","222","333");
        Set<String> result=jedis.smembers("key");
        System.out.println(result);
    }
    public static void test02(Jedis jedis){
        System.out.println("sismember");
        jedis.flushAll();

        jedis.sadd("key","111","222","333");
        System.out.println(jedis.sismember("key","111"));
        System.out.println(jedis.sismember("key","2"));
    }

    public static void test03(Jedis jedis){
        System.out.println("scard");
        jedis.flushAll();

        jedis.sadd("key","111","222","333");
        System.out.println(jedis.scard("key"));

    }
    public static void main(String[] args) {
        JedisPool jedisPool=new JedisPool("tcp://127.0.0.1:8888");
        try(Jedis jedis=jedisPool.getResource()){
            test01(jedis);
            test02(jedis);
            test03(jedis);
        }
    }
}
